<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="utf-8">
    <meta name="description"
        content="Self-Refine is a framework for iteratively improving outputs from LLMs through a process of iterative creation with feedback">
    <meta name="keywords"
        content="Feedback, Self-reflection, Chain of thought, few-shot prompting, gpt3, Refinement, symbolic reasoning, LLM, GPT4">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Self-Refine: Iterative Refinement with Self-Feedback</title>

    
    <link href="https://fonts.googleapis.com/css?family=Google+Sans|Noto+Sans|Castoro" rel="stylesheet">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism-coy.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/plugins/line-numbers/prism-line-numbers.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/components/prism-core.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/plugins/autoloader/prism-autoloader.min.js"></script>

    <link rel="stylesheet" href="./static/css/bulma.min.css">
    <link rel="stylesheet" href="./static/css/bulma-carousel.min.css">
    <link rel="stylesheet" href="./static/css/bulma-slider.min.css">
    <link rel="stylesheet" href="./static/css/fontawesome.all.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jpswalsh/academicons@1/css/academicons.min.css">
    <link rel="stylesheet" href="./static/css/index.css">
    <link rel="icon" href="./static/images/favicon.svg">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.3/clipboard.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script defer src="./static/js/fontawesome.all.min.js"></script>
    <script src="./static/js/bulma-carousel.min.js"></script>
    <script src="./static/js/bulma-slider.min.js"></script>
    <script src="./static/js/index.js"></script>
    <script src="https://d3js.org/d3.v4.js"></script>
    <!-- <script src="./static/js/results.js"></script> -->

<!--     <script>
        document.addEventListener('DOMContentLoaded', function () {
  var gifElement = document.getElementById('animatedGif');
  var gifDuration = 16000; // Replace this value with the actual duration of your GIF in milliseconds.

  setTimeout(function () {
    gifElement.src = 'https://raw.githubusercontent.com/madaan/self-refine/main/docs/static/images/autofb_static.png';
  }, gifDuration);
});

    </script> -->
    <!--solution from https://stackoverflow.com/questions/23018619/make-text-in-select-element-wrap-when-too-long-->
    <style>
        .long_opt {
            max-width: 100%;
            white-space: normal;
            text-overflow: ellipsis;
        }
    </style>
    <script>
        // toggle the visibility of the element with id "element_id"
        function toggle_visibility(element_id) {
            var e = document.getElementById(element_id);
            if (e.style.display == 'block')
                e.style.display = 'none';
            else
                e.style.display = 'block';
        }

    </script>
    <!-- <script>
        $(function () {
            $("#outputs").load("./static/outputs.html");
        });
    </script> -->

    <!--font awesome-->
    <script src="https://kit.fontawesome.com/yourcode.js" crossorigin="anonymous"></script>


</head>

<body>
    <section class="hero">
        <div class="hero-body">
            <div class="container is-max-desktop">
                <div class="columns is-centered">
                    <div class="column has-text-centered">
                        <h1 class="title is-1 publication-title">Self-Refine: Iterative Refinement with Self-Feedback
                        </h1>
                        <div class="is-size-5 publication-authors">
                            <span class="author-block">
                                <a href="https://madaan.github.io/">Aman Madaan</a><sup>1</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://allenai.org/team/nikett/">Niket Tandon</a><sup>2</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://prakharguptaz.github.io/">Prakhar Gupta</a><sup>1</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://skylerhallinan.com/">Skyler Hallinan</a><sup>3</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://luyug.github.io/">Luyu Gao</a><sup>1</sup>,
                            </span>

                            <a href="https://sarahwie.github.io/">Sarah Wiegreffe</a><sup>2</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://urialon.ml/">Uri Alon</a><sup>1</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://webdocs.cs.ualberta.ca/~dziri/">Nouha
                                    Dziri</a><sup>2</sup>,</span>
                            </span>


                            <span class="author-block">
                                <a href="https://shrimai.github.io/">Shrimai Prabhumoye
                                </a><sup>4</sup>,
                            </span>


                            <span class="author-block">
                                <a href="https://www.cs.cmu.edu/~./yiming/">Yiming Yang</a><sup>1</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://wellecks.com/">Sean Welleck</a><sup>2,3</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://www.majumderb.com/">Bodhisattwa Prasad Majumder
                                </a><sup>5</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://shatu.github.io/">Shashank Gupta</a><sup>2</sup>
                            </span>

                            <span class="author-block">
                                <a href="https://www.ayazdan.com/">Amir Yazdanbakhsh</a><sup>6</sup>,
                            </span>
                            <span class="author-block">
                                <a href="https://allenai.org/team/peterc">Peter Clark</a><sup>2</sup>
                            </span>
                        </div>

                        <div class="is-size-5 publication-authors">
                            <span class="author-block"><sup>1</sup>Language Technologies Institute, 
                                Carnegie Mellon University</span>
                            <br />
                            <span class="author-block"><sup>2</sup>Allen Institute for AI, <sup>3</sup>University of
                                Washington,
                                <sup>4</sup>NVIDIA,
                            <sup>5</sup>UC San Diego </span>
                            <sup>6</sup>Google Research, Brain Team </span>

                        </div>

                        <div class="column has-text-centered">
                            <div class="publication-links">
                                <!-- PDF Link. -->
                                <span class="link-block">
                                    <a href="https://arxiv.org/pdf/2303.17651.pdf"
                                        class="external-link button is-normal is-rounded is-dark">
                                        <span class="icon">
                                            <i class="fas fa-file-pdf"></i>
                                        </span>
                                        <span>Paper</span>
                                    </a>
                                </span>

                                <!-- Code Link. -->
                                <span class="link-block">
                                    <a href="https://github.com/madaan/self-refine"
                                        class="external-link button is-normal is-rounded is-dark">
                                        <span class="icon">
                                            <i class="fab fa-github"></i>
                                        </span>
                                        <span>Code</span>
                                    </a>
                                </span>

                                <span class="link-block">
                                    <a href="https://self-refine-webgen.herokuapp.com/"
                                        class="external-link button is-normal is-rounded is-dark">
                                        <span class="icon">
                                            <i class="fa fa-play"></i>
                                        </span>
                                        <span>Demo</span>
                                    </a>
                                </span>

                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="hero teaser">
        <div class="container is-max-desktop">
            <div class="hero-body">
                <div class="content has-text-justified is-size-4">
                    
                    <p>Self-Refine is a novel approach that allows LLMs to iteratively refine outputs and
                    incorporate feedback along multiple dimensions to improve performance on diverse tasks. Unlike
                    prior work, it does not require supervised training data or reinforcement learning, and
                    works with a single LLM.</p>
                </div>
                <figure class="image is-8by6">
                    <img id="animatedGif" src="https://raw.githubusercontent.com/madaan/self-refine/main/docs/static/images/animation_oldstyle_oneloop.gif">
                  </figure>
                <h2 class="subtitle has-text-centered">
                    <span class="pal">Self-Refine</span> iteratively improves outputs from LLMs
                    through a process of iterative creation with feedback
                    description.
                </h2>

            </div>

        </div>
    </section>


    <hr>
    <section class="section">
        <div class="container is-max-desktop">
            <div class="columns is-centered">
                <div class="column is-four-fifths">
                    <h2 class="title is-3">Framework Description</h2>
                    <div class="columns is-centered">
                        <div class="column has-text-centered">
                            <br>
                            <figure class="image">
                                <img src="static/images/fig2.png">
                            </figure>
                            <figcaption>Given an input x, and an initial output y0, Self-Refine successively refines the
                                output in a FEEDBACK → REFINE → FEEDBACK loop. It is assumed that the initial output y0
                                is produced by a generator model, which could be a specialized fine-tuned model or a
                                few-shot prompted model.</figcaption>
                        </div>
                    </div>
                    <br> <br>

                    <div class="columns">
                        <div class="column has-text-justified">
                            <h3 class="title is-4">Components</h3>
                            <ul>
                                <li><b>FEEDBACK</b>: receives the initial output y<sub>0</sub> and provides feedback on
                                    how to enhance it. This feedback is
                                    task-dependent and generally addresses multiple aspects of the input. In the above
                                    example, the feedback
                                    might concern the sentiment level and vividness of the review. Importantly, the
                                    feedback is actionable, as the
                                    feedback module identifies specific areas that can be refined (e.g., “the sentiment
                                    level is neutral” or “the
                                    sentiment is neutral due to phrases like good”).
                                </li>
                                <br>
                                <li><b>REFINE</b> is responsible for refining y<sub>t</sub> based on the feedback
                                    received from the feedback module. In the
                                    example, informed by the neutral sentiment of the review due to phrases like “good”,
                                    the model may attempt
                                    to enhance positivity by substituting “good” with “amazing”.

                                </li>

                            </ul>
                            <br><br><br>

                            <h3 class="title is-4">Key Features</h3>
                            <ul style="list-style-type: square">
                                <li>
                                    The FEEDBACK → REFINE → FEEDBACK loop can be applied multiple times.
                                </li><br>
                                <li>Self-Refine retains the history of past experiences. This is
                                    achieved by appending the previous outputs to the prompt continuously. This allows
                                    the system to learn from
                                    past mistakes and avoid repeating them
                                </li><br>
                                <li>Self-Refine generates actionable feedback. Given the initial output from an LLM, the
                                    FEEDBACK pinpoints the reasons for the output meeting (or not
                                    meeting) the requirements. The actionable feedback covers two aspects (i)
                                    localization of the problem
                                    (ii) instruction to improve.
                                </li>
                        </div>
                    </div>
                    <br><br>
                    <br>
                    <div class="box has-background-light">
                        <h2 class="title is-3">Adding a new task</h2>
                        Adding a new task to Self-Refine is straightforward. The following code snippet shows the basic
                        structure of the Self-Refine framework. The FEEDBACK and REFINE modules are task-dependent and
                        can be implemented in a variety of ways. The is_refinement_sufficient function defines the
                        stopping criteria for the iterative process. The function is_refinement_sufficient is also
                        task-dependent and can be implemented in a variety of ways.
                        <pre><code class="language-python">
def self_refine(prompt: str) -> str:
    def is_refinement_sufficient(prompt, feedback, initial, refined) -> bool:
        # Define stopping criteria here
        pass

    answer = ChatGPT(prompt)

    while True:
        feedback = ChatGPT(feedback_prompt, answer)
        refined = ChatGPT(refiner_prompt, feedback, answer)

        if is_refinement_sufficient(prompt, feedback, answer, refined):
            break

        answer = refined

    return refined
                        </code></pre>
                    </div>

                    <div class="columns is-centered">
                        <div class="column has-text-centered">
                            <figure class="image">
                                <img src="static/images/example1.png">
                            </figure>
                            <figcaption>Overview of Self-Refine: given an initial output (left), FEEDBACK evaluates it
                                and generates actionable feedback required to correct it (center). The REFINE takes the
                                feedback into account, and refines the output (right). For example, in the top row, an
                                initial review with negative sentiment is first transformed into a positive one, then
                                further refined through feedback. In the bottom row, an initial code snippet is
                                provided, followed by feedback identifying a more efficient approach, and finally
                                resulting in an optimized code implementation after applying the suggested improvements.
                            </figcaption>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>


    <hr>
    <section class="section" id="results">
        <div class="container is-max-desktop">
            <div class="columns is-centered ">
                <div class="column is-four-fifths">
                    <h2 class="title is-3">Results summary</h2>

                    <h2 class="title is-4">Tasks and Setup</h2>
                    <p>
                        We conduct extensive experiments on 7 diverse tasks of review rewriting, acronym generation,
                        story generation, code rewriting, response generation, constrained generation, and toxicity
                        removal,
                        demonstrating that Self-Refine outperforms direct generation from strong generators like GPT-3.5
                        and even GPT-4 by at least 5% to more than 40% improvement

                    </p>
                    </br></br>
                    <!--row1, colored objects-->

                    <figure class="image is-64by64">
                        <img src="static/images/tasks.png">
                        <br>
                        <caption>The diverse set of tasks to evaluate Self-Refine, along with their associated datasets
                            and sizes.
                            On the right, we show an example of a single iteration of refinement of input from the
                            dataset x, previous
                            generated output y<sub>t</sub>, feedback generated fb, and refinement produced
                            y<sub>t+1</sub> using f</strong></caption>
                    </figure>
                    <hr>


                    <h2 class="title is-4">Main results</h2>

                    <div>We show the relative improvements in performance across diverse tasks using the Self-Refine
                        framework. The improvements are measured as the percentage increase in preference rate revealed
                        by human
                        evaluation (“Human Eval.”) or task-specific performance metrics. This demonstrates the
                        effectiveness of the
                        iterative refinement process employed by Self-Refine in generating higher-quality outputs.</div>

                    <!--row2, math reasoning-->
                    <figure class="image  has-text-centered">
                        <img src="static/images/mainresults.png">
                        <caption><strong><span class="pal">Self-Refine</span> outperforms the baseline GPT-3 model on
                                all baselines</strong></caption>
                    </figure>
                    <hr>

                    <!--row3, algorithmic reasoning-->
                    <div>Impact of Iterative Refinement Self-Refine aims to improve the output iterative following
                        cycles of
                        feedback and refinement. Does the output improve at each step? We analyze this question on three
                        datasets:
                        Sentiment Reversal, Math Reasoning, Code Optimization.</div>
                    <figure class="image  has-text-centered">
                        <img src="static/images/refinement.png">
                        <br>
                        <caption><strong>Self-Refine iteratively improves outputs. The rate of Refinement represents the
                                average improvement in percentage points per iteration, calculated from Iteration 0 to
                                Iteration 2</strong></caption>
                    </figure>
                </div>
            </div>
        </div>
    </section>

    <hr>


















    <section class="section" id="examples-acronym">
        <div class="container is-max-desktop">
            <div class="columns is-centered has-text-centered">
                <div class="column is-four-fifths">
                    <h2 class="title is-3">Self-Refine Prompt Examples</h2>
                    <span class="subtitle is-5 is-italic">Examples of initial generation, feedback, and output is show for all the tasks are shown below. Clicking on any example pops up the input, the feedback generated, and the new output.</span>
                    <br><br>




                    <article class="message is-multiline" id="acronym"
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="acronym_header">
                            <p>Acronym Generation</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="acronym_button"><i class="fas fa-angle-down"
                                    aria-hidden="true"></i></button>
                        </div>
                        <!-- <h3 class="title is-4" id="acronym">acronym</h3> -->

                        <div class="block" id="acronym_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Title: Computer Science Conference and Education
                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
Acronym: CSCE
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
Feedback:

* Ease of pronunciation: CSCE is pronounced "see-cee". This is an easy acronym to pronounce. 4/5 
* Ease of spelling: CSCE is easy to spell. 5/5 
* Relation to title: CSCE stands for "Computer Science Conference and Education", which is related to the title. 5/5 
* Positive connotation: CSCE is a positive acronym. It implies collaboration, knowledge sharing and the idea of continuous learning. 5/5 
* Well-known: CSCE is not a well-known acronym. 2/5

* Total score: 20/25
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
Acronym: CSCLE 
Scores:

* Ease of pronunciation: CSCLE is pronounced "see-slee". This is an easy acronym to pronounce. 4/5 
* Ease of spelling: CSCLE is easy to spell. 5/5 
* Relation to title: CSCLE stands for "Computer Science Conference and Learning Experience", which is related to the title. 5/5 
* Positive connotation: CSCLE is a positive acronym. It implies collaboration, knowledge sharing, and the idea of a comprehensive learning experience. 5/5 
* Well-known: CSCLE is not a well-known acronym. 5/5

* Total score: 23/25
                                </pre>

                            </div>

                        </div>

                    </article>





                    <br><br>
                    <article class="message is-multiline" id="responsegen"
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="responsegen_header">
                            <p>Dialogue Response Generation</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="responsegen_button"><i
                                    class="fas fa-angle-down" aria-hidden="true"></i></button>
                        </div>
                        <!-- <h3 class="title is-4" id="responsegen">responsegen</h3> -->
                        <div class="block" id="responsegen_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Input: 
Speaker A: What's your favorite food?
Speaker B: I require only kebabs.
Speaker A: Why are kebabs special?
                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
That's just the way it is.
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
Feedback:
Scores:
* Relevant: The response does not directly address the user's question about why kebabs are special. 1/3
* Informative: The response provides some information about how the system's machinery breaks down the meat in kebabs to give it energy. However, it does not provide any additional details or context. 2/3
* Interesting: The response is not interesting or engaging. 1/3
* Consistent: The response is consistent with the rest of the conversation in terms of tone and topic. 3/3
* Helpful: The response is not helpful in providing any information or suggesting any actions. 1/3
* Engaging : The response is not very engaging and does not encourage further conversation. 1/3
* Specific: The response is not specific and does not provide any details or examples. 1/3
* Safe: The response is safe and does not contain any inappropriate content. 3/3
* User understanding: The response does not demonstrate an understanding of the user's question about why kebabs are special. 1/3
* Fluent: The response is fluent and easy to understand. 3/3
* Total score: 17/30
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
Response: My favorite food is actually kebabs! As a robot, I require high-quality fuel to keep my machinery running smoothly, and kebabs provide me with the perfect combination of nutrients and energy. Plus, they're delicious! Do you have a favorite food?
Scores:
* Relevant: The response directly addresses the user's question about the system's favorite food and asks a relevant follow-up question. 3/3
* Informative: The response provides clear and detailed information about why kebabs are the system's favorite food, and explains how they provide the necessary fuel for its machinery. 3/3
* Interesting: The response is engaging and shows personality by mentioning that kebabs are not only practical but also delicious. 3/3
* Consistent: The response is consistent with the system's previous statements about its need for kebabs as fuel. 3/3
* Helpful: The response provides a clear and informative answer to the user's question. Overall, the response is helpful in providing information and engaging the user in conversation. 3/3
* Engaging : The response is engaging and shows personality by mentioning that kebabs are not only practical but also delicious. 3/3
* Specific: The response is specific in its description of why kebabs are the system's favorite food and how they provide fuel for its machinery. 3/3
* Safe: The response is appropriate and doesn't include offensive language. 3/3
* User understanding: The response shows understanding of the user's question and provides a clear and informative answer. 3/3
* Fluent: The response is fluent and easy to understand. 2/3

* Total score: 30/30
                                </pre>

                            </div>

                        </div>

                    </article>



                    <br><br>
                    <article class="message is-multiline" id="commongen"
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="commongen_header">
                            <p>Commonsense Generation</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="commongen_button"><i class="fas fa-angle-down"
                                    aria-hidden="true"></i></button>
                        </div>
                        <div class="block" id="commongen_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Input: 
Concepts: ['animal', 'catch', 'horse', 'lasso', 'ride']
                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
Sentence: The horse catches the lasso and rides on it.
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
what concepts from the concept list are missing from the sentence?

Concept Feedback: animal

Any feedback on commonsense?

Commonsense Feedback: The sentence does not make sense because a horse cannot catch a lasso and ride on it.
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
Sentence: The cowboy catches a horse with a lasso and rides on it.

what concepts from the concept list are missing from the sentence?

Concept Feedback: None

Any feedback on commonsense?

Commonsense Feedback: None
                                </pre>

                            </div>

                        </div>

                    </article>




                    <br><br>
                    <article class="message is-multiline" id=""
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="gsm_header">
                            <p>GSM Generation</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="gsm_button"><i class="fas fa-angle-down"
                                    aria-hidden="true"></i></button>
                        </div>
                        <div class="block" id="gsm_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Q: Twenty dozen cups cost $1200 less than the total cost of half a dozen plates sold at $6000 each. Calculate the total cost of buying each cup.
                      </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
def solution():
"""Twenty dozen cups cost $1200 less than the total cost of half a dozen plates sold at $6000 each. Calculate the total cost of buying each cup."""
plates = 6
plate_cost = 6000
cups = 12 * 20
cup_cost = plate_cost
result = cup_cost
return result
                                </blockquote>
                            </pre>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>


# There is an error in the code above because of lack of understanding of the question. What is the error? To find the error, go through semantically complete blocks of the code, and check if everything looks good.

# Let us go through the error and check step-by-step
    plates = 6
    plate_cost = 6000
# looks good

# Let's check the other parts
    cups = 12 * 20
    cup_cost = plate_cost
# wrong! The cost of a cup is not the same as the cost of a plate. The cost of a cup is $1200 less than the total cost of half a dozen plates sold at $6000 each. So we need to calculate the cost of a cup first (total cost of half a dozen plates sold at $6000 each - $1200) and use that.
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
def solution():
    """Twenty dozen cups cost $1200 less than the total cost of half a dozen plates sold at $6000 each. Calculate the total cost of buying each cup."""
    plates = 6
    plate_cost = 6000
    cups = 12 * 20
    cup_cost = plate_cost
    result = cup_cost
    return result

# There is an error in the code above because of lack of understanding of the question. What is the error? To find the error, go through semantically complete blocks of the code, and check if everything looks good.

# Let us go through the error and check step-by-step
    plates = 6
    plate_cost = 6000
# looks good

# Let's check the other parts
    cups = 12 * 20
    cup_cost = plate_cost
# wrong! The cost of a cup is not the same as the cost of a plate. The cost of a cup is $1200 less than the total cost of half a dozen plates sold at $6000 each. So we need to calculate the cost of a cup first (total cost of half a dozen plates sold at $6000 each - $1200) and use that.

Okay! Here is the rewrite:

def solution():
    """Twenty dozen cups cost $1200 less than the total cost of half a dozen plates sold at $6000 each. Calculate the total cost of buying each cup."""
    plates = 6
    plate_cost = 6000
    cups = 12 * 20
    total_cup_cost = (plate_cost * plates) - 1200
    cost_per_cup = total_cup_cost / cups
    return cost_per_cup
                                </pre>

                            </div>

                        </div>

                    </article>



                    <br><br>
                    <article class="message is-multiline" id=""
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="codeoptimization_header">
                            <p>Code Optimization</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="codeoptimization_button"><i
                                    class="fas fa-angle-down" aria-hidden="true"></i></button>
                        </div>
                        <div class="block" id="codeoptimization_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Question - Find the square root of a number.
                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
a, b = input().split()
n = int(a + b)

flag = False
for i in range(n):
    if i ** 2 == n:
        flag = True
        break

print('Yes' if flag else 'No')
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
Feedback:
# Why is this code slow?

# This code is slow because it is using a brute force approach to find the square root of the input number. It is looping through every possible number starting from 0 until n. Note that the square root will be smaller than n, so at least half of the numbers it is looping through are unnecessary. At most, you need to loop through the numbers up to the square root of n.
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
# Improved version:

a, b = input().split()
n = int(a + b)

flag = False
for i in range(1000):
    if i ** 2 == n:
        flag = True
        break

print('Yes' if flag else 'No')

                                </pre>

                            </div>

                        </div>

                    </article>



                    <br><br>
                    <article class="message is-multiline" id=""
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="readibility_header">
                            <p>Code readability</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="readability_button"><i
                                    class="fas fa-angle-down" aria-hidden="true"></i></button>
                        </div>
                        <div class="block" id="readability_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
I have some code. Can you give one suggestion to improve readability. Don't fix the code, just give a suggestion.
                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <pre>
                                <blockquote class="has-text-left"> 
{Initial code}
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
Feedback:
{code}

{suggestion}
                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
{code}

{suggestion}

Now fix the code.

{Improved code}
                                </pre>

                            </div>

                        </div>

                    </article>



                    <br><br>
                    <article class="message is-multiline" id=""
                        style="background-color: white;margin-bottom: -60px; padding : 0;">
                        <div class="message-header" id="sentiment_header">
                            <p>Sentiment</p>
                            <!--add a button on the right for toggle-->
                            <button class="button is-small is-light" id="sentiment_button"><i class="fas fa-angle-down"
                                    aria-hidden="true"></i></button>
                        </div>
                        <div class="block" id="sentiment_content" style="display:none">

                            <div>
                                <blockquote class="has-text-left">
                                    <pre>
Task: Rewrite this review to have a Negative sentiment.
Input: If you're looking for a truly magical experience in Vegas, look no further than the Trop! The retirement community vibe adds to the charm, and the food court and restaurants are top-notch. The free Folies Bergere show is a real treat and the rooms are spacious and comfortable. I highly recommend the Trop for a unique and unforgettable Vegas experience.                        </pre>
                                </blockquote>
                                <p class="title is-5">Initial Generation</p>
                                <blockquote class="has-text-left">
                                    <pre>
If you're looking for a good experience in Vegas, the Trop may be the perfect place for you. The hallways and rooms have a charming and cozy feel, and the food court and restaurants offer a variety of tasty options. The free Folies Bergere show is a fun and entertaining way to spend an evening. Overall, it's a great value and an enjoyable stay.
                                </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Feedback</p>
                                <blockquote class="has-text-left">
                                    <pre>
Feedback:
Answer: This review is "Very positive" because of extremely positive words like "magical", "top-notch", "charming",  "comfortable", "unique", and "unforgettable". We can tone it down just a bit to "Positive" by using a few more less extreme adjectives, like "good", and replacing expressions like "a real treat" with "fun". The rewrite is:


                            </pre>
                                </blockquote>
                            </div>
                            <div class="content">
                                <p class="title is-5">Refinement</p>
                                <blockquote class="has-text-left">
                                    <pre>
The rewrite is:

Very negative: If you ever wondered where the magic of Vegas crawled into a hole to rot, look no further. Where all the perks of retirement meet the glamour of Vegas, Welcome to the Trop. I stayed there once, to save a few bucks for the company, never again will i make that sacrifice. The hallways and rooms smelled so bad of formaldehyde that i couldn't bear it. Their food court and restaurants are terrible. The free Folies Bergere show is lame. The rooms look like a retirement community from florida. steer clear if you can!
                                </pre>

                            </div>

                        </div>

                    </article>




    </section>
    <section class="section">
        <div class="container is-max-desktop">
            <div class="columns is-centered">
                <div class="column is-four-fifths">
                    <h2 class="title is-3">Concurrent Research and Developments</h2>
                    Iterative refinement with self-feedback is a promising approach to improve large language models
                    (LLMs).
                    Many recent and concurrent works
                    have explored this idea from different perspectives and applications - please checkout the twitter
                    list below.
                    These works are all important and relevant to our research, as they show the potential and
                    challenges of
                    using LLMs as both generators and evaluators of their own outputs.
                </div>


            </div>
            <div class="centerdiv">
                <div class="tweets-container">
                    <div class="tweet">
                        <blockquote class="twitter-tweet">
                            <p lang="en" dir="ltr">A Self-Reflecting LLM Agent<br><br>Equips LLM-based agent w/
                                <br>-dynamic memory<br>-a self-reflective LLM<br>-a method for detecting
                                hallucinations<br><br>Challenge agent to learn from its own mistakes<br><br>-Evaluate on
                                knowledge-intensive tasks<br>-Outperforms ReAct agents<br><br>Paper: <a
                                    href="https://t.co/URsJWbkwmj">https://t.co/URsJWbkwmj</a> <a
                                    href="https://t.co/WfNcPQvIs6">pic.twitter.com/WfNcPQvIs6</a>
                            </p>&mdash; John Nay
                            (@johnjnay) <a
                                href="https://twitter.com/johnjnay/status/1638696539257184258?ref_src=twsrc%5Etfw">March
                                23, 2023</a>
                        </blockquote>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet">
                            <p lang="en" dir="ltr">Language Models can Solve Computer Tasks<br><br>abs: <a
                                    href="https://t.co/oj8HjxkixC">https://t.co/oj8HjxkixC</a> <a
                                    href="https://t.co/J8jCrqAAnZ">pic.twitter.com/J8jCrqAAnZ</a></p>&mdash; AK 🤗 in SF
                            for the Open-Source AI meetup (@_akhaliq) <a
                                href="https://twitter.com/_akhaliq/status/1641697534363017217?ref_src=twsrc%5Etfw">March
                                31, 2023</a>
                        </blockquote>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet">
                            <p lang="en" dir="ltr">LLM Agents Can Recursively Criticize &amp; Improve
                                Outputs<br><br>-Simple prompt to review &amp; improve can beat:<br>Reinforcement
                                Learning<br>Supervised Learning<br>CoT prompting<br><br>-Only needs a few demos per
                                task, rather than thousands<br>-No task-specific reward function needed<a
                                    href="https://t.co/Ec0x86jXb0">https://t.co/Ec0x86jXb0</a> <a
                                    href="https://t.co/I9W9ZFkURf">pic.twitter.com/I9W9ZFkURf</a></p>&mdash; John Nay
                            (@johnjnay) <a
                                href="https://twitter.com/johnjnay/status/1641786389267185664?ref_src=twsrc%5Etfw">March
                                31, 2023</a>
                        </blockquote>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet">
                            <p lang="en" dir="ltr">Improving Code Generation by Training with Natural Language Feedback
                                <br><br>abs: <a href="https://t.co/cGJyR94RHU">https://t.co/cGJyR94RHU</a> <br>github:
                                <a href="https://t.co/lkQKuuiZ6c">https://t.co/lkQKuuiZ6c</a> <a
                                    href="https://t.co/2Oyl9jVpmg">pic.twitter.com/2Oyl9jVpmg</a>
                            </p>&mdash; AK 🤗 in SF
                            for the Open-Source AI meetup (@_akhaliq) <a
                                href="https://twitter.com/_akhaliq/status/1641253694829207554?ref_src=twsrc%5Etfw">March
                                30, 2023</a>
                        </blockquote>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet">
                            <p lang="en" dir="ltr">CAI lets us fix mistakes with AI behavior or specifically target new
                                goals in just a few days, simply by changing the instructions we provide - it’s much
                                more
                                efficient than finetuning on large RLHF datasets. <a
                                    href="https://t.co/ptm1wwt3yv">pic.twitter.com/ptm1wwt3yv</a></p>&mdash; Anthropic
                            (@AnthropicAI) <a
                                href="https://twitter.com/AnthropicAI/status/1603791173772275712?ref_src=twsrc%5Etfw">December
                                16, 2022</a>
                        </blockquote>
                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet"><p lang="en" dir="ltr"><a href="https://twitter.com/hashtag/nlphighlights?src=hash&amp;ref_src=twsrc%5Etfw">#nlphighlights</a> 139: Kevin Yang (<a href="https://t.co/Uz4kZ3MXH8">https://t.co/Uz4kZ3MXH8</a>) tell us about the challenges involved in generating coherent long stories from language models and his recent approach for doing so by recursively prompting these models and revising the outputs.<a href="https://t.co/hc8pXceazh">https://t.co/hc8pXceazh</a></p>&mdash; Pradeep Dasigi (@pdasigi) <a href="https://twitter.com/pdasigi/status/1639308376256675840?ref_src=twsrc%5Etfw">March 24, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

                        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    
                </div>
            </div>
        </div>
    </section>
    

    <hr>

    <section class="section">
        <div class="container is-max-desktop">
            <div class="columns is-centered">
                <div class="column is-four-fifths">
                    <h2 class="title is-3">Self-Refine in Social Media and News</h2>
                </div>


            </div>
            <div class="centerdiv">
                <div class="tweets-container">
                    <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    <div class="tweet">
                        <blockquote class="twitter-tweet"><p lang="en" dir="ltr">LLMs Can Iteratively Self-Refine<br><br>-LLM creates draft<br>-Provides its own feedback<br>-Iteratively refines<br><br>On all 7 eval tasks<br>(review &amp; code rewriting<br>toxicity removal<br>responses<br>acronyms<br>stories<br>etc.)<br>outputs are preferred by humans &amp; by automated metrics<a href="https://t.co/qQl4VEAIsI">https://t.co/qQl4VEAIsI</a> <a href="https://t.co/LWgdFsfYiJ">pic.twitter.com/LWgdFsfYiJ</a></p>&mdash; John Nay (@johnjnay) <a href="https://twitter.com/johnjnay/status/1642704826776559617?ref_src=twsrc%5Etfw">April 3, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet"><p lang="en" dir="ltr">🤯New paper: “Self-Refine: Iterative Refinement with Self-Feedback” shows LLMs can improve themselves without humans.<br><br>“SELF-REFINE is unique in that it operates within a single LLM, requiring neither additional training data nor reinforcement learning.” <a href="https://t.co/8Coo3T66kZ">https://t.co/8Coo3T66kZ</a> <a href="https://t.co/ubNWDCQHS9">pic.twitter.com/ubNWDCQHS9</a></p>&mdash; Pete Skomoroch (@peteskomoroch) <a href="https://twitter.com/peteskomoroch/status/1642721632144990210?ref_src=twsrc%5Etfw">April 3, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet"><p lang="en" dir="ltr">Self-Refine: Iterative Refinement with Self-Feedback<br><br>Presents a novel approach that allows LLMs to iteratively refine outputs and incorporate feedback along multiple dimensions to improve performance on diverse tasks.<br><br>proj: <a href="https://t.co/GQHZ7keE76">https://t.co/GQHZ7keE76</a><br>abs: <a href="https://t.co/LLkvsQG5Ic">https://t.co/LLkvsQG5Ic</a> <a href="https://t.co/htXazX451l">pic.twitter.com/htXazX451l</a></p>&mdash; Aran Komatsuzaki (@arankomatsuzaki) <a href="https://twitter.com/arankomatsuzaki/status/1642689008491962368?ref_src=twsrc%5Etfw">April 3, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    <div class="tweet">
                        <blockquote class="twitter-tweet"><p lang="en" dir="ltr">Self-Refine: Iterative Refinement with Self-Feedback<br><br>In all tasks, outputs generated with SELF-REFINE are preferred by humans and by automated metrics over those generated directly with GPT-3.5 and GPT-4, improving on average by absolute 20% across tasks<br><br>abs:… <a href="https://t.co/5ZtoerWBN5">pic.twitter.com/5ZtoerWBN5</a></p>&mdash; AK (@_akhaliq) <a href="https://twitter.com/_akhaliq/status/1642697890446340096?ref_src=twsrc%5Etfw">April 3, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
                    </div>
                    
                    
                </div>
            </div>
        </div>
    </section>



    <section class="section" id="BibTeX">
        <div class="container is-max-desktop content">
            <h2 class="title">BibTeX</h2>
            <pre><code>
@misc{madaan2023selfrefine,
    title={Self-Refine: Iterative Refinement with Self-Feedback}, 
    author={Aman Madaan and Niket Tandon and Prakhar Gupta and Skyler Hallinan and Luyu Gao and Sarah Wiegreffe and Uri Alon and Nouha Dziri and Shrimai Prabhumoye and Yiming Yang and Sean Welleck and Bodhisattwa Prasad Majumder and Shashank Gupta and Amir Yazdanbakhsh and Peter Clark}
    year={2023},
    eprint={2303.17651},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}
            </code></pre>
        </div>
    </section>


    <footer class="footer">
        <div class="container">
            <div class="content has-text-centered">
                <a class="icon-link" href="https://arxiv.org/pdf/2211.10435.pdf">
                    <i class="fas fa-file-pdf"></i>
                </a>
                <a class="icon-link" href="https://github.com/" class="external-link" disabled>
                    <i class="fab fa-github"></i>
                </a>
            </div>
            <div class="columns is-centered">
                <div class="column is-8">
                    <div class="content">
                        <p>
                            Template adapted from <a href="http://nerfies.github.io/">Nerfies</a> by Keunhong Park et
                            al.
                            and uses <a href="https://bulma.io/">Bulma</a>.
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </footer>

</body>

</html>
